/*
 * @Descripttion: 
 * @version: 
 * @Author: 某人
 * @Date: 2021-04-28 14:08:06
 */
function render(template, data) {
  const reg = /\{\{(\w+)\}\}/
  // 判断模板里是否有模板字符串
  if (reg.test(template)) {
    // 把大括号中的key值取出来
    const name = reg.exec(template)[1]
    template = template.replace(reg, data[name])
    return render(template, data)
  }
  return template
}
let template = '我是{{name}}，年龄{{age}}，性别{{sex}}';
let person = {
  name: '布兰',
  age: 12
}
console.log(render(template, person))